package linkedlist.exercise;

import java.util.*;
import java.util.concurrent.CompletableFuture;

class MinStack {
    public static void main(String[] args) {

        Deque<Integer> deque = new LinkedList<>();
        deque.isEmpty();
        Map map = new HashMap<>();
        Queue<Integer> queue = new LinkedList();
        char c = '2';
        Integer i = (int)c;
        System.out.println(Character.isDigit('2'));
    }

     static int calculate(String s) {
        Deque<Integer> ops = new LinkedList();
        ops.push(1);
        int res = 0;
        int sign = 1;
        for(int i = 0; i < s.length(); ++i) {
            if(s.charAt(i) == ' ') {
                continue;
            } else if(s.charAt(i) == '+') {
                sign = ops.peek();
            } else if(s.charAt(i) == '-') {
                sign = -ops.peek();
            } else if(s.charAt(i) =='(') {
                ops.push(sign);
            } else if(s.charAt(i) ==')') {
                ops.pop();
            } else {
                int num = 0;
                while(i < s.length() && Character.isDigit(s.charAt(i))) {
                    num = num * 10 + s.charAt(i) - '0';
                    i++;
                }
                res = res + sign * num;
            }
        }
        return res;
    }

    Stack<Integer> stack;
    Stack<Integer> minStack;
    int min = Integer.MAX_VALUE;
    /** initialize your data structure here. */
    public MinStack() {
        stack = new Stack();
        minStack = new Stack();
    }
    
    public void push(int val) {
        if(val < min) {
            min = val;
        }
        stack.push(val);
        minStack.push(min);
    }
    
    public void pop() {
        stack.pop();
        minStack.pop();
        min = minStack.peek();
    }
    
    public int top() {
        return stack.peek();
    }
    
    public int getMin() {
        return min;
    }
}